
import React, { useCallback, useState, useContext, forwardRef } from 'react'
import CustomizeModal, { CustomizeModalButton, CustomizeModalContext } from "@common/presentational/CustomizeModal";
import { Input, Row, Col } from "antd";

const BindPlatformContent = props => {
    const { hide, params } = useContext(CustomizeModalContext)
    const { id } = params
    const [info, setInfo] = useState('')


    const handleNameChange = useCallback(e => {
        setInfo(e.currentTarget.value)
    }, [])

    const submitBindPlatform = () => {
        const { callBack } = props
        callBack(id,info)
        console.log('submitBindPlatform', info)
        hide()
    }

    return (
        <>
            <Row className="modal-line">
                <Col span={20}>
                    <Input placeholder='输入平台门店编码' value={info} onChange={handleNameChange} />
                </Col>
            </Row>
            <CustomizeModalButton
                onOk={submitBindPlatform}
                onCancel={hide}
            />
        </>
    )
}

export default forwardRef((props, ref) => (
    <CustomizeModal title="配送平台绑定" ref={ref}>
        <BindPlatformContent {...props} />
    </CustomizeModal>
))
